package com.tubi.testIO;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class ioDemo6 {
    public static void main(String[] args) throws IOException {
       /* //复制文件
        //读取数据
        FileInputStream f = new FileInputStream("/Users/ronglei/Desktop/学习/a.txt");
        //写文件
        FileOutputStream x = new FileOutputStream("test-IO/a.txt");
        int b;
        while ((b=f.read())!=-1){
            x.write(b);
        }
        f.close();
        x.close();*/


            //复制多个 提高拷贝速度
        //复制文件
        //读取数据
        FileInputStream f = new FileInputStream("/Users/ronglei/Desktop/学习/a.txt");
        //写文件
        FileOutputStream x = new FileOutputStream("test-IO/a.txt");
        byte [] bytes = new byte[1024];
        int len;
        while ((len=f.read(bytes))!=-1){
            x.write(bytes,0,len);
        }
        f.close();
        x.close();
    }
}
